package me.zhengjie.rest;

import me.zhengjie.utils.SerialNumberUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpStatus;

import java.util.List;

@RestController()
@RequestMapping("/api")
public class SerialNumberController {

    @Autowired
    private SerialNumberUtil serialNumberUtil;

    @GetMapping("/generateSerialNumber")
    public ResponseEntity<String> generateSerialNumber(@RequestParam String type) {
        String serialNumber = serialNumberUtil.generateSerialNumber(type);
        return new ResponseEntity<>(serialNumber, HttpStatus.OK);
    }

    @GetMapping("/generateBatchSerialNumbers")
    public ResponseEntity<List<String>> generateBatchSerialNumbers(@RequestParam String type, @RequestParam int batchSize) {
        List<String> serialNumbers = serialNumberUtil.generateBatchSerialNumbers(type, batchSize);
        return new ResponseEntity<>(serialNumbers, HttpStatus.OK);
    }
}
